package com.wwwarehouse.usercenter.adapter;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.wwwarehouse.usercenter.R;
import com.wwwarehouse.usercenter.bean.authoritydistribute.GetSuccessDetailResponseBean;

import java.util.List;

/**
 * @author : mundane
 * @time : 2017/9/24 13:48
 * @description :
 * @file : AuthorityDistributeAllDetailRvAdapter.java
 */
public class AuthorityDistributeAllDetailRvAdapter extends RecyclerView.Adapter<AuthorityDistributeAllDetailRvAdapter.AuthorityDistributeAllDetailRvAdapterHolder> {

	private List<GetSuccessDetailResponseBean.ListBean> mDataList;

	public AuthorityDistributeAllDetailRvAdapter(List<GetSuccessDetailResponseBean.ListBean> dataList) {
		this.mDataList = dataList;
	}

	@Override
	public AuthorityDistributeAllDetailRvAdapterHolder onCreateViewHolder(ViewGroup parent, int viewType) {
		View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_rv_authority_distribute_all_detail, parent, false);
		return new AuthorityDistributeAllDetailRvAdapterHolder(view);
	}

	@Override
	public void onBindViewHolder(AuthorityDistributeAllDetailRvAdapterHolder holder, int position) {
		GetSuccessDetailResponseBean.ListBean authNameBean = mDataList.get(position);
		// process data
		holder.mTvAuthName.setText(authNameBean.authName);
		holder.mTvTime.setText(String.format("%s至%s", authNameBean.authStartStr, authNameBean.authEndStr));
	}

	@Override
	public int getItemCount() {
		return mDataList == null ? 0 : mDataList.size();
	}

	static class AuthorityDistributeAllDetailRvAdapterHolder extends RecyclerView.ViewHolder {

		TextView mTvTime;
		TextView mTvAuthName;

		public AuthorityDistributeAllDetailRvAdapterHolder(View itemView) {
			super(itemView);
			mTvAuthName = (TextView) itemView.findViewById(R.id.tv_auth_name);
			mTvTime = (TextView) itemView.findViewById(R.id.tv_time);
		}
	}
}
